


$(function () {
    $(".tree-btn").click(function (event) {
        var self = $(this);
        var dialog = $('#tree-dialog');
        dialog.modal('show');
        var tr = self.parent().parent();
        let user_id = tr.attr('data-id');

        $("#treelist").empty();
        $("#treelist").kendoTreeList({
                dataSource: {
                    transport: {
                        read: {
                            url:  "http://192.168.0.117:5000/index/ztree/?user_id=" + user_id,
                            dataType: "json"
                        }
                    },
                    schema: {
                        model: {
                            id: "id",
                            parentId: "p_id",
                            fields: {
                                id: { field: "id",  nullable: true },
                                p_id: { field: "p_id" ,nullable: true }
                            },
                        }
                    },
                },
                height: 540,
                // filterable: true,
                sortable: true,
                columns: [
                    // { field: "id", title: "ID", width: 280,
                    //     template: $("#photo-template").html() },
                    { field: "phone", title: "手机号"},
                    { field: "name" ,title:"名字"},
                    // { field: "Phone", width: 200 },
                    // { field: "Extension", width: 140 },
                    // { field: "Address" }
                ],
                // pageable: {
                //     pageSize: 15,
                //     pageSizes: true
                // }
            });


        // savebtn.attr("data-type",'update');
        // savebtn.attr("data-id",tr.attr('data-id'));
    })
});



